// Copyright (c) 2017 Florian Klampfer <https://qwtel.com/>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

.heading {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-heading);
}

.f1 {
  @extend .heading;
  font-size: 2rem;
  line-height: 1.3;
}

.f2 {
  @extend .heading;
  font-size: 1.5rem;
  line-height: 1.4;
}

.f3 {
  @extend .heading;
  font-size: 1.2em;
  line-height: 1.5;
}

.f4 {
  @extend .heading;
  font-size: 1.08rem;
  line-height: 1.6;
}

.f5 {
  @extend .heading;
  font-size: 1.04rem;
  line-height: 1.7;
}

.f6 {
  @extend .heading;
  font-size: 1rem;
}

// <<< INLINE
h1, .h1 { @extend .f1; }
h2, .h2 { @extend .f2; }
h3, .h3 { @extend .f3; }
h4, .h4 { @extend .f4; }
h5, .h5 { @extend .f5; }
h6, .h6 { @extend .f6; }

.content {
  h1, .h1 {
    > a { text-decoration: none; border-bottom: none; }
    @media screen and (max-width: $break-point-1) {
      font-size: 1.7rem;
      line-height: 1.35;
    }
    @media screen and (min-width: $break-point-5) {
      font-size: 2.4rem;
      line-height: 1.25;
    }
  }
}

body:not(.no-large-headings) {
  .content {
    h1, .h1 {
      @media screen and (min-width: $break-point-dynamic) {
        width: calc(100% + 50vw - 32rem);
        font-size: 3rem;
        line-height: 1.2;
      }
      @media screen and (min-width: $break-point-font-large) {
        font-size: 4rem;
        line-height: 1.1;
      }
    }
  }
}

h1, h2, h3, .h1, .h2, .h3 {
  margin: 4rem 0 1rem;
}

h4, h5, h6, .h4, .h5, .h6 {
  margin: 3rem 0 .5rem;
}

p {
  margin-top: 0;
  margin-bottom: 1rem;

  &.lead {
    font-size: 1.2em;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
  }
}

ul, ol, dl {
  margin-top: 0;
  margin-bottom: 1rem;
}

ul, ol {
  padding-left: 1.25rem;
}

hr, .hr {
  @extend .color-transition;
  border: 0;
  margin: 1rem 0;
  border-top: 1px solid var(--border-color);
}

.hr-after::after {
  @extend .color-transition;
  content: "";
  display: block;
  margin: 1rem 0;
  border-top: 1px solid var(--border-color);
}

.hr-bottom {
  @extend .color-transition;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: .75rem;
  margin-bottom: 1rem;
}

// >>>>>

// <<<<< LINK
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6, .heading {
  text-rendering: optimizeLegibility;
}

h1 + h2, .h1 + .h2, h1 + .h2, .h1 + h2,
h2 + h3, .h2 + .h3, h2 + .h3, .h2 + h3,
h3 + h4, .h3 + .h4, h3 + .h4, .h3 + h4,
h4 + h5, .h4 + .h5, h4 + .h5, .h4 + h5,
h5 + h6, .h5 + .h6, h5 + .h6, .h5 + h6 {
  margin-top: 0;
}

dt, strong {
  font-weight: var(--font-weight-bold);
}

dt:after{
  content: " :";
  color: var(--menu-text);
}

dd {
  margin-bottom: .5rem;
}

abbr {
  font-size: 85%;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;

  &[title] {
    cursor: help;
    border-bottom: 1px dotted var(--border-color);
  }
}

blockquote {
  @extend .color-transition;
  padding: .5rem 1rem;
  margin: .8rem 0;
  color: var(--gray);
  border-left: .25rem solid var(--border-color);

  &.lead {
    font-size: 1.2em;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    border-left-width: 0.4rem;
  }

  > p:last-child {
    margin-bottom: 0;
  }
}

.heading {
  font-weight: var(--font-weight-heading);
}

.fine, .smaller {
  font-size: smaller;
}

.faded {
  @extend .color-transition;
  color: var(--gray);
}

.centered {
  text-align: center;
}

h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
  position: relative;

  > .permalink {
    text-decoration: none;
    border: none;
    opacity: 0;
    transition: opacity 400ms;

    @media print {
      display: none;
    }
  }

  &:hover > .permalink {
    opacity: 0.5;
  }

  & > .permalink:hover,
  & > .permalink:focus {
    opacity: 1;
    transition: opacity 200ms;
  }
}

.content-hash::before {
  content: '#'
}
.content-json::before {
  content: '{}'
}

@media print {
  h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6, dt {
    page-break-inside: avoid;
    break-inside: avoid-page;
    page-break-after: avoid;
    break-after: avoid-page;
  }
}
// >>> LINK
